import { Column, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn, Unique } from "typeorm";
import { Category } from "./category.entity";

@Entity()
export class Book {
  @PrimaryGeneratedColumn()
  id: number;

  // 文件名
  @Column()
  @Unique(['fileName'])
  fileName: string;

  // 封面
  @Column()
  cover: string;

  // 书名
  @Column()
  title: string;

  // 作者
  @Column()
  author: string;

  // 出版社
  @Column({ nullable: true })
  publisher: string;


  @Column({ nullable: true })
  bookId: string;

  // // 分类
  // @Column()
  // category: number;

  // // 分类名称
  // @Column()
  // categoryText: string;

  // 语言
  @Column()
  language: string;

  // 根文件地址
  @Column()
  rootFile: string;

  @Column({ nullable: true })
  originalName: string;

  @Column({ nullable: true })
  filePath: string;

  @Column({ nullable: true })
  unzipPath: string;

  @Column({ nullable: true })
  coverPath: string;

  @Column({ nullable: true })
  createUser: string;

  @Column({ nullable: true })
  createDt: number;

  @Column({ nullable: true })
  updateDt: number;

  @Column({ nullable: true })
  updateType: number;

  // 分类
  @ManyToOne(() => Category, (category) => category.book)
  @JoinColumn({ name: "categoryId" })
  category: Category;
}
